<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Shop_model extends CI_Model {

    function get_shop($shop_id) {
        return $this->db
                ->select('id,shop_title,shop_description,shop_category,shop_link,shop_facebook,shop_instagram,shop_color,shop_level,shop_level0_cover,shop_level0_description,shop_level1_cover,shop_level1_description')
                ->where('id', $shop_id)
                ->get('shops')
                ->row_array();
    }
    
    function get_shop_all_data($shop_id) {
        return $this->db
                ->where('id', $shop_id)
                ->get('shops')
                ->row_array();
    }
    
    function get_recent_approve_list()
    {
        return $this->db
                ->select('id,shop_title,shop_link,shop_facebook,shop_instagram,shop_color,shop_level,shop_level0_cover,shop_level0_description,shop_level1_cover,shop_level1_description')
                ->where('is_approved',1)
                ->order_by('approved_at','DESC')
                ->limit(10)
                ->get('shops')
                ->result_array();
    }
    
    function get_recent_updated_list()
    {
        return $this->db
                ->select('id,shop_title,shop_link,shop_facebook,shop_instagram,shop_color,shop_level,shop_level0_cover,shop_level0_description,shop_level1_cover,shop_level1_description')
                ->where('is_approved',1)
                ->where('modified_at !=',0)
                ->order_by('modified_at','DESC')
                ->limit(10)
                ->get('shops')
                ->result_array();
    }
    
    function get_shop_list($category) {
        return $this->db
                ->select('id,shop_title,shop_link,shop_facebook,shop_instagram,shop_color,shop_level,shop_level0_cover,shop_level0_description,shop_level1_cover,shop_level1_description')
                ->where('shop_category', $category)
                ->where('is_approved',1)
                ->order_by('is_sticky','DESC')
                ->order_by('active_view_score','DESC')
                ->get('shops')
                ->result_array();
    }
    
    function get_pending_shop_list($category)
    {
        return $this->db->where('shop_category', $category)->where('is_approved',0)->get('shops')->result_array();
    }
    
    function get_category_title($category)
    {
        switch($category)
        {
            case 'women':
                return 'Women (คุณผู้หญิง)';
            case 'men':
                return 'Men (ท่านชาย)';
            case 'kids':
                return 'Kids (คุณหนู)';
            case 'pets':
                return 'Pets (สัตว์เลี้ยง)';
            case 'mobiles-it':
                return 'Mobiles & IT (มือถือและไอที)';
            case 'gadgets-hobbies':
                return 'Gadgets & Hobbies (ของเล่นและงานอดิเรก)';
        }
    }

}